<!--#include file="utf-8.asp"-->
<!--#include file="conn.asp"-->
<!--#include file="seeion.asp"-->
<!--#include file="page.asp"-->
<!--#include file="sqlerr.asp" -->
<script language="javascript">
function showUploadDialog(s_Type, s_Link, s_Thumbnail){
var arr = showModalDialog("eWebEditor/dialog/i_upload.htm?style=popup&type="+s_Type+"&link="+s_Link+"&thumbnail="+s_Thumbnail, window, "dialogWidth:0px;dialogHeight:0px;help:no;scroll:no;status:no");}
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="images/style.css" type="text/css" rel="stylesheet" />
</head>
<body>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td class="head"><strong>增加友情链接</strong></td>
  </tr>
  <tr>
    <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"  class="head_chile">
      <tr>
        <td width="28%">网站名称</td>
        <td width="28%">链接地址</td>
        <td width="28%">&nbsp;LOGO地址</td>
        <td width="5%" align="center">排序</td>
        <td width="10%" align="center">操作</td>
      </tr>
    </table>
        <form action="Manage_FriendLinks.asp?type=add" method="post" name="form" id="form">
          <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td width="28%" height="30"><label>
                <input name="Title" type="name" class="textbox" id="Title" />
              </label></td>
              <td width="28%" height="30"><input name="url" type="text" class="textbox" id="url" value="http://" /></td>
              <td width="28%" height="30"><p>
                  <input name="logo_url" type="text" class="textbox" id="logo_url" />
                  <input type="button" value="上传" onclick="showUploadDialog('image', 'form.logo_url', '')" />
              </p></td>
              <td width="5%" height="30" align="center"><input name="ordersID" type="text" class="textbox" id="ordersID" size="2" /></td>
              <td width="10%" height="30" align="center"><input name="button2" type="submit" class="button_01" id="button2" value="增加链接" /></td>
            </tr>
          </table>
        </form></td>
  </tr>
</table>
<br />
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td class="head"><strong>友情链接管理</strong></td>
</tr>
<tr>
<td>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="head_chile">
<tr>
<td width="28%">网站名称</td>
<td width="28%">链接地址</td>
<td width="28%">&nbsp;LOGO地址</td>
<td width="5%" align="center">排序</td>
<td width="5%" align="center">修改</td>
<td width="5%" align="center">删除</td>
</tr>
</table>
<%	
set rs=server.createobject("adodb.recordset") 
exec="select * from FriendLinks order by ordersID asc" 
rs.open exec,conn,1,1 
if rs.eof then
response.Write "&nbsp;暂无友情链接！"
else
rs.PageSize =20 '每页记录条数
iCount=rs.RecordCount '记录总数
iPageSize=rs.PageSize
maxpage=rs.PageCount 
page=request("page")
if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if
if page<1 then
page=1
elseif  page>maxpage then
page=maxpage
end if
rs.AbsolutePage=Page
if page=maxpage then
x=iCount-(maxpage-1)*iPageSize
else
x=iPageSize
end if	
%>
<%For i=1 To x%>
<form  name="form<%=i%>" method="post" action="Manage_FriendLinks.asp?type=update">
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td width="28%" height="30"><input name="Title" type="text" class="textbox" id="Title" value="<%=rs("Title")%>"></td>
    
    <input name="id" type="hidden" id="id" value="<%=rs("id")%>" />
    
    <td width="28%" height="30"><input name="url" type="text" class="textbox" value="<%=rs("url")%>"></td>
    <td width="28%" height="30"><input name="logo_url" type=text class="textbox" value="<%=rs("logo_url")%>"></td>
    <td width="5%" height="30" align="center"><input name="ordersID" type="text" class="textbox" value="<%=rs("ordersID")%>" size="2"></td>
    <td width="5%" height="30" align="center"><a href="javascript:this.form<%=i%>.submit();">修改</a></td>
    <td width="5%" height="30" align="center"><a href="javascript:if(confirm('确定删除？删除后不可恢复!')){window.location.href='Manage_FriendLinks.asp?type=del&amp;id=<%=rs("id")%>&amp;actions=<%=actions%>';}else{history.go(0);}">删除</a> </td>
    </tr>
    </table>
</form>
<%rs.movenext
next
%>
<%end if%>
<br />
<%'以下显示分页
call PageControl(iCount,maxpage,page,"border=0 align=center","<p align=center>")
rs.close
set rs=nothing
%></td>
</tr>
</table>
<br>
</body>
</html>

<% 
if Request.QueryString("type")="update" then

	id=request("id") 
	
	sql="select * from FriendLinks where id="&id 
	set rs=server.CreateObject("adodb.recordset")
	rs.open sql,conn,1,3
	
	IF not isNumeric(request("ordersID")) then
		response.write("<script>alert(""排序ID必须为数字！""); history.go(-1);</script>")
		response.end
	end if
	
	rs("Title")=request.form("Title") 
	rs("url")=request.form("url") 
	rs("logo_url")=request.form("logo_url") 
	rs("ordersID")=request.form("ordersID") 
	rs.update 
	
	rs.close
	set rs=nothing
	conn.close
	set rs=nothing
	response.Write("<script language=""javascript"">alert(""修改链接成功！"");window.location.href='Manage_FriendLinks.asp';</script>")
	end if
%> 

<%
if Request.QueryString("type")="add" then

	set rs=server.createobject("adodb.recordset")
	sql="select title,url,logo_url,ordersID from FriendLinks"
	rs.open sql,conn,1,3
	
	Title=request.form("Title")
	url=request.form("url")
	logo_url=request.form("logo_url")
	ordersID=request.form("ordersID")
	
	if Title=""  then 
		response.Write("<script language=javascript>alert('网站名称不能为空!');history.go(-1)</script>") 
		response.end 
	end if
	if url=""  then 
		response.Write("<script language=javascript>alert('网站地址不能为空!');history.go(-1)</script>") 
		response.end 
	end if
	if ordersID="" then 
		response.Write("<script language=javascript>alert('排序ID不能为空!');history.go(-1)</script>") 
		response.end 
	end if
	IF not isNumeric(request("ordersID")) then
		response.write("<script>alert(""排序ID必须为数字！""); history.go(-1);</script>")
		response.end
	end if
	
	rs.addnew
	rs("Title")=Title
	rs("url")=url
	rs("logo_url")=logo_url
	rs("ordersID")=ordersID
	rs.update
	
	rs.close
	set rs=nothing
	conn.close
	set rs=nothing
	
	Response.Write "<script>alert('增加链接成功！');window.location.href='Manage_FriendLinks.asp';</script>" 
end if
%>

<%
if request("type")="del" then

	id=request("id")
	
	if id="" then
		Response.Write "<script language='javascript'>alert('参数错误!');document.location.href('Manage_FriendLinks.asp');</script>"
		Response.End()
	end if
	
	sql="Select * from FriendLinks where id="&Request("id")
	set rs=server.createobject("adodb.recordset")
	rs.open sql,conn,1,3
	
	if rs.bof and rs.eof then
		Response.Write "<script language='javascript'>alert('数据库中没有该记录！');document.location.href('Manage_FriendLinks.asp');</script>"
		Response.End()
	else
		rs.Delete
		rs.Update
		
		rs.close
		set rs=nothing
		conn.close
		set rs=nothing
		
		Response.Write "<script language='javascript'>alert('成功删除指定的信息！');document.location.href('Manage_FriendLinks.asp');</script>"
	end if
end if
%>

